import java.util.Scanner;

public class demo004 {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int a=scan.nextInt();
        if(a>=1000&&a<=9999) {
            int b=a/1000;
            int c=(a-1000*b)/100;
            int d=(a-1000*b-100*c)/10;
            int e=(a-1000*b-100*c-10*d);
            System.out.println(b);
            System.out.println(c);
            System.out.println(d);
            System.out.println(e);
            System.out.println(b+c+d+e);
        }
        else{
            System.out.println("输入有误");
        }
    }


}
